package priv.pfz.basedao.sharding;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author yyjxp
 * 2024/2/2 22:49
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ShardingInfo {
    /**
     * 分库后缀
     */
    private String dbSuffix;

    /**
     * 分表后缀
     */
    private String tableSuffix;

    /**
     * 第三方分库分表信息（追加在SQL末尾）
     */
    private String thirdShardingStr;

    public static ShardingInfo empty() {
        return new ShardingInfo();
    }

    public static ShardingInfo db(String dbSuffix) {
        return new ShardingInfo(dbSuffix, "", "");
    }

    public static ShardingInfo table(String tableSuffix) {
        return new ShardingInfo("", tableSuffix, "");
    }

    public static ShardingInfo dbTable(String dbSuffix, String tableSuffix) {
        return new ShardingInfo(dbSuffix, tableSuffix, "");
    }

    public static ShardingInfo third(String thirdShardingStr) {
        return new ShardingInfo("", "", thirdShardingStr);
    }

    public ShardingInfo copy() {
        return new ShardingInfo(dbSuffix, tableSuffix, thirdShardingStr);
    }
}
